import React, { useRef, useImperativeHandle, forwardRef, useEffect } from 'react'

const Child = forwardRef((props, ref) => {
	const childRef = useRef()

	const click = () => {
		console.log(2222)
	}

	useImperativeHandle(ref, () => ({
		click: click,
		childDom: childRef,
	}))

	return <div ref={childRef}>child</div>
})

const Parent = () => {
	const cRef = useRef()
	useEffect(() => {
		console.log(cRef.current)
		console.log(cRef.current.childDom)
		console.log(cRef.current.chiclickldDom)
	}, [])

	return (
		<div>
			Home
			<Child ref={cRef} />
		</div>
	)
}

export default Parent
